{% import "TopxiaWebBundle::macro.html.twig" as web_macro %}
 {{ load_script('course-manage/header') }}
<div class="es-section course-manage-header clearfix">
  <a href="{{ path('course_show', {id:course.id}) }}">
    <img class="picture" src="{{ filepath(course.largePicture, 'course.png') }}" />
  </a>
  <h1 class="title">
    {% if course.type != 'normal' %}
      [{{ dict('courseType')[course.type] }}]
    {% endif %}
    <a class="link-dark" href="{{ path('course_show', {id:course.id}) }}">{{ course.title }}</a>
    {% if course.status=='closed' %}
      <span class="label label-danger ">{{'已关闭'|trans}}</span>
    {% elseif course.status=='draft' %}
      <span class="label label-warning ">{{'未发布'|trans}}</span>
    {% elseif course.status=='published' %}
      {% if course.serializeMode=='serialize' %}
        <span class="label label-success ">{{'更新中'|trans}}</span>
      {% elseif course.serializeMode=='finished' %}
        <span class="label label-warning ">{{'已完结'|trans}}</span>
      {% endif %}
    {% endif %}
  </h1>

  <div class="teachers">
    {% if course.teacherIds|default(null) %}
      {{'教师：'|trans}}
      {% for id in course.teacherIds %}
        {% set user = users[id] %}
        <a href="{{ path('user_show',  {id:user.id}) }}" >{{ user.nickname }}</a>
      {% endfor %}
    {% endif  %}
  </div>

  <div class="toolbar hidden-xs">
    {% if course.status == 'published' %}
      <div class="btn-group">
        <a class="btn btn-default btn-sm" href="{{ path('course_show', {id:course.id}) }}">{{'返回课程主页'|trans}}</a>
      </div>
    {% endif %}

    <div class="btn-group">
      <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">{{'预览'|trans}} <span class="caret"></span></button>
      <ul class="dropdown-menu pull-right">
        <li><a href="{{ path('course_show', {id:course.id, previewAs:'member'}) }}" target="_blank">{{'作为 已购买用户'|trans}}</a></li>
        <li><a href="{{ path('course_show', {id:course.id, previewAs:'guest'}) }}" target="_blank">{{'作为 未购买用户'|trans}}</a></li>
      </ul>
    </div>

    {% if course.status != 'published' %}
      <div class="btn-group">
        <button class="btn btn-success btn-sm course-publish-btn" data-url="{{ path('course_manage_publish', {id:course.id}) }}">{{'发布课程'|trans}}</button>
      </div>
    {% endif %}
  </div>
</div>
{% if course.status == 'closed' %}
<div class="alert alert-warning">课程已关闭，在有效期内的学员仍可正常学习，若不希望学员继续学习，需在【学员管理】中移除学员。</div>
{% endif %}